#@layout()

#define main()
#set(isAdd = account == null ? true : false, isEdit = !isAdd)

<div class="jfa-header-box" id="jfa-header-box">
	<div class="jfa-crumbs" id="jfa-crumbs">
		<a href="#(ctx)/admin/account">账户管理</a> / #(isAdd ? "创建" : "修改")
	</div>

	<div class="jfa-search-box"></div>
	#include("/_view/common/_header_right.html")
</div>


<div class="jfa-content-box" id="jfa-content-box">
	<div class="jfa-content" id="jfa-content">
		<form class="form-horizontal margin-top-30" id="accountForm" action="#(ctx)/admin/account/#(isAdd ? 'save' : 'update')" method="post">

			#if (isEdit)
			<input type="hidden" name="account.id" value="#(account.id)" />
			#end

			<div class="form-group">
				<label class="col-sm-4 control-label">姓名</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" autocomplete="new-password" name="account.realName" value="#(account.realName??)">
				</div>
			</div>
			
			
			<div class="form-group">
				<label class="col-sm-4 control-label">账号</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" autocomplete="new-password" name="account.userName" value="#(account.userName??)">
				</div>
			</div>
			
			
			<div class="form-group">
				<label class="col-sm-4 control-label">员工号</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" autocomplete="off" name="account.employeeNumber" value="#(account.employeeNumber??)">
				</div>
			</div>
			
			#if (isAdd)
			<div class="form-group">
				<label class="col-sm-4 control-label">密码</label>
				<div class="col-sm-8">
					<input type="password" class="form-control" autocomplete="new-password" name="account.password" value="#(account.password??)">
				</div>
			</div>
			#end
			
			<div class="form-group">
				<div class="col-sm-offset-4 col-sm-8">
					<input class="btn btn-primary" type="submit" value="提交" />
				</div>
			</div>
		</form>
	</div><!-- END OF jfa-content -->
</div><!-- END OF jfa-content-box -->

<style type="text/css">
	#accountForm {
		width: 500px;
	}

	.form-group {
		margin-bottom: 25px;
	}

	.jfa-content label {
		line-height: 1;
		vertical-align: baseline;
		color: #23527c;
		font-size: 20px;
		font-weight: normal;
		margin-bottom: 8px;;
	}
</style>

<script type="text/javascript">
	$(document).ready(function() {
		$("#accountForm").ajaxForm({
			dataType: "json"
			, beforeSubmit: function(formData, jqForm, options) {}
			, success: function(ret) {
				if (ret.state == "ok") {
					location.href = "#(ctx)/admin/account";
				} else {
					showFailMsg(ret.msg);
				}
			}
			, error: function(ret) {alert(ret.statusText);}
			, complete: function(ret) {} 	      // 无论是 success 还是 error，最终都会被回调
		});
	});
</script>
#end